<?php
class Zend_LearnController extends Zend_Controller_Action{
    public function taoForm(){
        $form = new Zend_Form();
        $form->setAction('success');
        $form->setMethod('post');
        $form->setDescription('Dang ky tai khoan');
        $form->setAttrib('sitename','loudbite');
        
        $form->addElement('text','taikhoan');
        $taikhoan = $form->getElement('taikhoan');
        $taikhoan->setLabel('Username :');
        $taikhoan->setOrder(1)->setRequired(true);
        
        $form->addElement('password','matkhau');
        $matkhau = $form->getElement('matkhau');
        $matkhau->setLabel('Password :');
        $matkhau->setOrder(2)->setRequired(true);
        
        $form->addElement('text','email');
        $email = $form->getElement('email');
        $email->setLabel('Email :');
        $email->setOrder(3)->setRequired(true);
        
        $form->addElement('submit','submit');
        $submit = $form->getElement('submit');
        $submit->setLabel('Create');
        $submit->setOrder(4);
        
        return $form;
    }
    public function indexAction(){
        $form = $this->taoForm();
        $this->view->quan = $form;
    }
    public function successAction(){
        $form = $this->taoForm();
        if($form->isValid($_POST)){
            $fillall = 1;
            $username = $form->getValue('taikhoan');
            $this->view->taikhoan = $username;
            $this->view->checking = $fillall;
        }else{
            $fillall = 0;
            $username = 'but you have to fill all your information';
            $this->view->taikhoan = $username;
            $this->view->checking = $fillall;
        }
    }
}
?>